<!--#include file="./header.inc"-->
<%
if not isSuper then
    admin.message "权限不足"
end if

dim logDir
logDir = root & "log/"
select case aq
	case "detail"     	: 	call detail
	case "download" 	: 	call download
	case "delete" 		: 	call delete
	case else 			: 	call index
end select

call db.close()

'列表
function index()
    dim list
    list = admin.fileList(logDir)
    infoTotal = list(0)
    temp = list(1)
    %><!--#include file="./view/log.index.html"--><%
end function

'查看
function detail()
	dim fn
    fn = trim(request("fn"))
    if fn = "" then
        admin.message "文件名为空"
    end if
    fn = logDir & fn
    data = app.loadFile(fn, 1)
    %><!--#include file="./view/log.detail.html"--><%
end function

'下载
function download()
    dim fn
    fn = trim(request("fn"))
    admin.download logDir & fn
end function

'删除
function delete()
    dim fns, fn, j, result
    fns = request("fn").count
    if fns = 0 then app.json "没有文件！", 1
    j = 0
    for i = 1 to fns
        fn = trim(request("fn")(i))
        result = app.deleteFile(logDir & fn)
        if result then j = j + 1
    next
    if j > 0 then
        app.json "删除 " & j & " 个文件成功", 0
    else
        app.json "删除失败", 1
    end if
end function
%>